package com.hengxinguotong.hxgtwygsp.ui.newView.periodicReport;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.hengxinguotong.hxgtwygsp.R;
import com.hengxinguotong.hxgtwygsp.model.Rule;
import com.hengxinguotong.hxgtwygsp.ui.base.BaseDialogActivity;
import com.hengxinguotong.hxgtwygsp.ui.readFile.FileDisplayActivity;
import com.hengxinguotong.hxgtwygsp.ui.regulation.RuleAdapter;
import com.hengxinguotong.hxgtwygsp.utils.CommUtil;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

/**
 * 定期报告
 * Created by CS-Yong
 * 2019/9/2  0:14
 */
public class PeriodicReportActivity extends BaseDialogActivity {
    @BindView(R.id.rule_recycler)
    RecyclerView mRuleRecycler;

    private RuleAdapter mAdapter;
    private List<Rule> mList = new ArrayList<>();
    
    
    @Override
    public int getLayoutResId() {
        return R.layout.activity_periodic_report;
    }

    @Override
    public void init() {
        mockView();

        mAdapter = new RuleAdapter(R.layout.item_rule,mList);
        LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        mRuleRecycler.setLayoutManager(manager);
        mRuleRecycler.setAdapter(mAdapter);


        mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                Rule rule = mList.get(position);
                FileDisplayActivity.show(PeriodicReportActivity.this, rule.getTitle(), CommUtil.getDataDir(PeriodicReportActivity.this) + File.separator + rule.getFileName());
            }
        });
    }

    @OnClick(R.id.member_close)
    public void onViewClicked() {
        finish();
    }

    private void mockView() {
        mList.add(new Rule("2019年第二季度","2019-07-01","periodic_report_19_2.docx"));
        mList.add(new Rule("2019年第一季度","2019-04-01","null.docx"));
    }
}
